<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8" />
  <meta http-equiv="X-UA-Compatible" content="IE=edge" />
  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
  <title>Document</title>
</head>

<body>
  <script>
    const obj = {
      uname: '张三',
      age: 18,
      family: {
        baby: '小阿三',
      },
    }
    // const newObj = {}
    // Object.assign(newObj, obj)
    // newObj.uname = '老王'
    // console.log(newObj);
    // console.log(obj);
    // //复杂数据类型拷贝的是地址
    // newObj.family.baby = '小小王'
    // console.log(newObj);
    // console.log(obj);
    const o = { ...obj }
    console.log(o);
    o.family.baby = '小龙龙'
    console.log(obj);
  </script>
</body>

</html>